# -*- coding:utf-8 -*-
from common.database_tools import RedisTools
from common.log import log


def get_redis_connect(conf):
    return RedisTools(conf["host"], conf["prot"], conf["db"], conf["password"])


def duplicate_removal_push(datas, keys, conf, l=10000):
    """
    存储种子数据
    :param datas:
    :param keys:
    :param conf:
    :return:
    """
    rtl = get_redis_connect(conf)
    dt_len = len(datas)
    count = (dt_len + l - 1) // l
    for c in range(count):
        log.info(f"第{c + 1}次上传")
        end = dt_len if c + 1 == count else (c + 1) * l
        rtl.push_set_data(keys, str(datas[c * l:end]))
    log.info(f"存储种子结束")
    del rtl


def get_set_values(keys, conf):
    rtl = get_redis_connect(conf)
    values = rtl.get_set_data(keys)
    del rtl
    return values
